﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Ext.Net;
using Sio.Mdm.Entities;
using Sio.Mdm.BF.Ldap;
using Sio.Mdm.Types.Database;
using Sio.Mdm.Web.Controls;

namespace Sio.Mdm.Web.Instalacija
{
    public partial class LdapLogiPodrobno : Controls.Page
    {
        #region Properties
        int LogID
        {
            get
            {
                return Request.GetValue<int>("LogID");
            }
        }        
        #endregion

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack && !X.IsAjaxRequest)
            {
                if (LogID > 0)
                {
                    LoadLog(LogID);
                }                
            }
        }

        private void LoadLog(int logId)
        {
            LdapLogRazsirjeno log = EntityFactory.LoadEntity<LdapLogRazsirjeno>(
            new Filter<LdapLogRazsirjeno>().Where(r => r.LdapLogID == logId));

            txtOrgarnizacija.Text = log.OrgarnizacijaNaziv;
            txtStreznikIme.Text = log.StreznikIme;
            txtStreznikOpis.Text = log.StreznikOpis;
            txtStreznikNaslov.Text = log.StreznikNaslov;
            txtStreznikRootDN.Text = log.StreznikRootDN;
            txtPraviloIme.Text = log.PraviloIme;
            txtPraviloOpis.Text = log.PraviloOpis;

            txtDodano.Text = log.CountIns.ToString();
            txtPosodobljeno.Text = log.CountUpd.ToString();
            txtBrisano.Text = log.CountDel.ToString();
            
            txtCasSec.Text = log.PorabljenCas.ToString();

            txtPorocilo.Text = log.Porocilo;  
            txtOpozorilo.Text = log.Opozorilo; if (String.IsNullOrEmpty(log.Opozorilo)) txtOpozorilo.Visible=false;
            txtNapaka.Text = log.Napaka; if (String.IsNullOrEmpty(log.Napaka)) txtNapaka.Visible = false;
        }

        protected void ButtonClicked(object sender, DirectEventArgs e)
        {
            DialogButtons button = e.DeserializeParameter<DialogButtons>("buttonType");
            
        }
    }
}
